package com.mark.controller.common;

import com.mark.common.ServerResponse;
import com.mark.util.VerificationCodeUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * Created by Choisaaaa on 2018/5/7.
 * 验证码验证
 */
@Controller
@RequestMapping("/code/")
public class VerifyCodeController {

    @RequestMapping(value = "check.do", method = RequestMethod.GET)
    @ResponseBody
    public ServerResponse checkVerifyCode(HttpSession session,String codeValue){
       if(VerificationCodeUtil.checkVerifyCode(codeValue,session)){
           return  ServerResponse.createBySuccess();
       }
        return ServerResponse.createByErrorMessage("输入的验证码不正确！");
    }
}
